package com.bw.controller;

import com.bw.entity.Bing;
import com.bw.entity.Dict;
import com.bw.mapper.BingMapper;
import org.spring.kun.common.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class BingController {

    @Autowired
    BingMapper bingMapper;

    @RequestMapping("/bingPage.do")
    public String bingPage(Model model){

        //1渲染过滤条件的下拉框
        List<Dict> sourceList = bingMapper.selectSourceList();
        model.addAttribute("sourceList",sourceList);
        return "bing";
    }

    @RequestMapping("/bing.do")
    @ResponseBody
    public List<Bing> bing(Integer sourceId, String status){

        List<Bing> list = bingMapper.bing(sourceId,status);

        return list;
    }
    @RequestMapping("/excelBing.do")
    public void excelBing(Integer sourceId, String status, HttpServletResponse response){

        List<Bing> list = bingMapper.bing(sourceId,status);

        ExcelUtils.exportExcel(list,"人才信息统计表","人才信息统计表1",response);
    }
}
